﻿using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AI_Tank.Game
{
    class ParseLegEndData
    {
        private LegEndData legEndDataObj;
        public ParseLegEndData(string legEndData)
        {
            JObject obj = JObject.Parse(legEndData);
            List<Teams> list = new List<Teams>();
            JArray arr = JArray.Parse(obj["msg_data"]["teams"].ToString());
            for (int i = 0; i < arr.Count; i++)
            {
                Teams team = new Teams();
                team.SetTeamData(Int32.Parse(arr[i]["id"].ToString()), Int32.Parse(arr[i]["point"].ToString()));
                list.Add(team);
            }
            legEndDataObj = new LegEndData(list);
        }
        public LegEndData GetLegEndDataObj()
        {
            return legEndDataObj;
        }
    }
}
